<template>
	<view class="content bg_com">
		<view class="main_box">
			<view class="_item row_center">
				<view class="sl row_center">
					<image class="icon" src="../../static/jb.png" mode="scaleToFill"></image>
					{{wallet.goldNum}}
				</view>
				<view v-if="platform !== 'ios'" class="btn_warp row_center" @click="jumpCz">
					充值
					<i class="iconfont icon-arrow-right"></i>
				</view>
				<image class="img_val" src="../../static/w_bg1.png" mode=""></image>
			</view>
			<view class="_item row_center">
				<view class="sl row_center">
					<image class="icon" src="../../static/zs.png" mode="scaleToFill"></image>
					{{wallet.diamondNum}}
				</view>
				<view class="btn_warp row_center" @click="jumpDh">
					兑换
					<i class="iconfont icon-arrow-right"></i>
				</view>
				<image class="img_val" src="../../static/w_bg2.png" mode=""></image>
			</view>
		</view>
		<com-modal :title="msgTitle" :smMsg="smMsg" :confirmBtn="confirmBtn" @confirm="focusRemove" :msg="msg" ref="modal" />
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex';
	import comModal from '@/components/com-modal/com-modal.vue'
	export default {
		computed: mapState(['hasLogin', 'identity', 'wallet', 'user']),
		data() {
			return {
				diamondNum: 0,
				goldNum: 0,
				platform: 'ios',
				msg: '赠送，充值，提现等功能限制使用',
				msgTitle: '限制提示',
				confirmBtn: '知道了',
				smMsg: '（我的-青少年模式-可关闭）'
			}
		},
		onLoad() {
			this.updateWallet();

			let platform = '';
			switch (uni.getSystemInfoSync().platform) {
				case 'android':
					console.log("安卓")
					this.platform = 'android';
					break;
				case 'ios':
					console.log("ios")
					this.platform = 'ios';
					break;
				default:
					console.log("其他")
					this.platform = 'other';
					break;
			}
		},
		methods: {
			...mapActions(['updateWallet']),
			jumpCz() {
				if(this.user.securityMode + '' === '1') {
					this.$refs.modal.open();
					return;
				}
				uni.navigateTo({
					url: 'recharge/recharge'
				})
			},
			jumpDh() {
				if(this.user.securityMode + '' === '1') {
					this.$refs.modal.open();
					return;
				}
				uni.navigateTo({
					url: 'diamond/diamond'
				})
			},
			/* 取消关注某人 */
			focusRemove() {
				console.log("点击确定")
				this.$refs.modal.close();
			},
		}
	}
</script>

<style lang="scss">
	@import "@/static/iconfont/iconfont.css";

	@font-face {
		font-family: 'iconfont';
		src: url('~@/static/iconfont/iconfont.ttf');
	}

	@import './index.scss';
</style>
